package net.scrumtool.technics;

import java.io.InputStream;

import net.scrumtool.view.SplashScreen;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;

public class Utils {

	// COLORS
	public static Color COLOR_BAR_1 = new Color(null, 29, 126, 168);
	public static Color COLOR_BAR_2 = new Color(null, 24, 91, 138);

	public static String IMG_FOLDER = "net/scrumtool/images";
	public static String IMG_LOGO = IMG_FOLDER + "/logo.png";

	// ICONES
	public static String IMG_ADD = IMG_FOLDER + "/ico_add.png";
	public static String IMG_DEL = IMG_FOLDER + "/ico_del.png";
	public static String IMG_EDIT = IMG_FOLDER + "/ico_edit.png";
	public static String IMG_OPEN = IMG_FOLDER + "/ico_open.png";
	public static String IMG_PROFILE = IMG_FOLDER + "/ico_profile.png";
	public static String IMG_LOGOUT = IMG_FOLDER + "/ico_logout.png";
	public static String IMG_HELP = IMG_FOLDER + "/ico_help.png";
	public static String IMG_SAVE = IMG_FOLDER + "/ico_save.png";

	// ICON
	public static String IMG_ICON = IMG_FOLDER + "/icon.png";

	// ICON _TAB_FOLDER
	public static String IMG_SPRINT = IMG_FOLDER + "/ico_sprint.png";
	public static String IMG_COLLABORATOR = IMG_FOLDER + "/ico_collaborator.png";
	public static String IMG_DASHBOARD = IMG_FOLDER + "/ico_dashboard.png";
	public static String IMG_PRODUCT = IMG_FOLDER + "/ico_product.png";
	public static String IMG_CALENDAR = IMG_FOLDER + "/ico_calendar.png";

	// ICON OVERVIEW PRODUCT
	public static String IMG_SUMMARY = IMG_FOLDER + "/ico_summary.png";
	public static String IMG_RECENT = IMG_FOLDER + "/ico_recent_sprint.png";
	public static String IMG_TODO = IMG_FOLDER + "/ico_todo.png";
	public static String IMG_INPROGRESS = IMG_FOLDER + "/ico_inprogress.png";
	public static String IMG_DONE = IMG_FOLDER + "/ico_done.png";

	public static Image getImage(String filename) {
		Image img = null;
		try {
			InputStream input = SplashScreen.class.getClassLoader().getResourceAsStream(filename);
			img = new Image(Display.getDefault(), input);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return img;
	}

	public static void addTransparentImage(final Image img, Composite compo) {
		compo.addPaintListener(new PaintListener() {

			@Override
			public void paintControl(PaintEvent pEvt) {
				pEvt.gc.drawImage(img, 0, 0);

			}
		});
	}

	public static void MsgBox(Shell shell, String message, String type) {
		MessageBox box;
		if (type == "information") {
			box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
			box.setText("SCRUMTOOL");
			box.setMessage(message);
			box.open();
		} else if (type == "error") {
			box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
			box.setText("SCRUMTOOL");
			box.setMessage(message);
			box.open();
		}
	}

}
